//
//  UILabel+UILabel_EXtension.m
//  OCweibo
//
//  Created by 郑兆远 on 15/12/22.
//  Copyright © 2015年 zzy. All rights reserved.
//

#import "UILabel+UILabel_EXtension.h"

@implementation UILabel (UILabel_EXtension)
+ (instancetype)labelWithTitle:(NSString*)title color:(UIColor*)color fontSize:(CGFloat)fontSize margin:(CGFloat)margin{
    UILabel *label = [[self alloc]init];
    if (label) {
        label.text = title;
        label.textColor = color;
        label.font = [UIFont systemFontOfSize:fontSize];
        label.numberOfLines = 0;
        label.textAlignment = NSTextAlignmentCenter;
        if (margin > 0) {
            label.preferredMaxLayoutWidth = [UIScreen mainScreen].bounds.size.width - 2 *margin;
            label.textAlignment = NSTextAlignmentLeft;
        }
        [label sizeToFit];
    }
    return label;
}
@end
